using System.Collections.Generic;
using UnityEngine;

public class PromoItem : MonoBehaviour
{
	[SerializeField]
	public UITexture mainPromoTexture;

	[SerializeField]
	public UITexture bonuseMoneyTexture;

	[SerializeField]
	public UIBasicSprite[] carPromoTexture;

	[SerializeField]
	public UIBasicSprite[] gunPromoTexture;

	[SerializeField]
	public UILabel promoName;

	[SerializeField]
	public UILabel countPromo;

	public InAppPromoController.InAppPromo info;

	public InAppSubscriptionsController.InAppPromo subscribeInfo;

	public bool isCashPromo;

	public PromoactionsManagerUI promoactionsManagerUI;

	public GameObject productPowerInfo;

	public UILabel productPowerCount;

	private void OnClick()
	{
		if (isCashPromo)
		{
			StartCoroutine(MarketControllerUI.instance.ShowBank(MoneyType.Cash));
		}
		else
		{
			StartCoroutine(MarketControllerUI.instance.ShowBank());
		}
	}

	private void Update()
	{
		if (info != null)
		{
			countPromo.text = info.GetPacksLeftAmount().ToString();
		}
		else if (subscribeInfo != null)
		{
			countPromo.text = subscribeInfo.GetPacksLeftAmount().ToString();
		}
	}

	public void OnDrag(Vector2 delta)
	{
		if (promoactionsManagerUI != null)
		{
			promoactionsManagerUI.StopAutoScroll();
		}
	}

	public void SetProductPower(List<string> productRewardIDs)
	{
		float num = 0f;
		if (productRewardIDs != null)
		{
			foreach (string productRewardID in productRewardIDs)
			{
				Product product = MarketController.Instance.GetProduct(productRewardID);
				if (product != null)
				{
					if (product is ProductWeapon)
					{
						num = (product as ProductWeapon).damage;
						break;
					}
					if (product is ProductTank)
					{
						num = (product as ProductTank).damage;
						break;
					}
					if (product is ProductTitan)
					{
						num = (product as ProductTitan).mainWeaponDamage;
						break;
					}
				}
			}
		}
		if (num > 0f)
		{
			productPowerCount.text = ((int)num).ToString();
			productPowerInfo.SetActive(true);
		}
		else
		{
			productPowerInfo.SetActive(false);
		}
	}
}
